//
//  LSZProductManagementViewController.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/10/27.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZProductManagementViewController.h"

@interface LSZProductManagementViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong) UITableView * tableViewIndustry;
@property(nonatomic,strong) LSZIndustryManager *industryManager;

 @end

@implementation LSZProductManagementViewController
//activity/list?catalogid

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"项目管理";
    [self getDataIndustry];
    [self initWIthBarButtonItem];
    self.tableViewIndustry.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
    [self.tableViewIndustry registerClass:[LSZDocumentdetailsCell class] forCellReuseIdentifier:@"LSZDocumentdetailsCellProduct"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.industryManager.arrayData.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0001;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZDocumentdetailsCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZDocumentdetailsCellProduct" forIndexPath:indexPath];
    cell.imageViewBrowse.hidden = YES;
    cell.labelBrowse.hidden = YES;
    if (self.industryManager.arrayData.count > indexPath.row) {
        LSZIndustryMg * mg = nil;
        mg = self.industryManager.arrayData[indexPath.row];
        cell.industryMg = mg;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.industryManager.arrayData.count > indexPath.row) {
        LSZIndustryDetailsViewController * vc = [[LSZIndustryDetailsViewController alloc]init];
        LSZIndustryMg * mg = nil;
        mg = self.industryManager.arrayData[indexPath.row];
        vc.industryMg = mg;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
-(UITableView *)tableViewIndustry
{
    if (_tableViewIndustry == nil) {
        _tableViewIndustry = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height) style:UITableViewStylePlain];
        _tableViewIndustry.delegate = self;
        _tableViewIndustry.dataSource = self;
        _tableViewIndustry.estimatedRowHeight=0;
        _tableViewIndustry.estimatedSectionFooterHeight =0;
        _tableViewIndustry.estimatedSectionHeaderHeight =0;
        [_tableViewIndustry setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        [self.view addSubview:_tableViewIndustry];
    }
    return _tableViewIndustry;
}
-(void)getDataIndustry
{
    [LSZRequestDicData detailsOfIndustryClassification:self.id_id :^(BOOL isOK, NSString * string,  LSZIndustryManager * manager) {
        if (isOK == YES) {
            self.industryManager = manager;
            [self.tableViewIndustry reloadData];
        }else{
            if ([string isEqualToString:@"重复登录"]) {
                [LSZPublicClassDataToll RepeatLoginInterfaceJump:self.view fromVC:@"LSZLiteratureViewController"];
            }else{
                [LSZPublicClassDataToll initWithAlertKuangView:self.view string:string];
            }
        }
    }];
}
-(void)initWIthBarButtonItem
{
    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"添加"] style:UIBarButtonItemStylePlain target:self action:@selector(clickReleaseItem)];
    self.navigationItem.rightBarButtonItem = rightBarItem;
}
-(void)clickReleaseItem
{
    LSZAddedIndustryManagementVC * VC = [[LSZAddedIndustryManagementVC alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}


@end
